<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
            {{msg}}
           <!-- <children v-model="msg"></children> -->
           <children @input='getMsg' ref="a"></children>
           <!-- ref相当于id -->
    </div>
   <template id="children">
        <div>
            {{msg}}
            <button @click="pushMsg">子传父</button>
        </div>
   </template>

   <script>
       Vue.component('children',{
        template:"#children",
        methods:{
            pushMsg(){
                this.$emit('input',this.msg)
            }
        },
        data(){
            return{
                msg:"1111"
            }
        }
       })

       new Vue({
           el:"#app",
           data:{
               msg:'1234'
           },
           methods:{
               getMsg(val){
                   this.msg = val
               }
           },
           mounted(){
                console.log(this.$refs['a']);
           }
       })
   </script>
</body>
</html>